<%@ page language="java"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <title>材料库存</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!-- 引用新样式 start -->
    <jsp:include page="../../jsp/public.jsp" flush="true"/>
    <!-- end -->
    <style type="text/css">
        .textBtn {
            position: absolute;
            right: 10px;
            bottom: 10px;
            top: 45px;
            right: 18px;
        }
    </style>
    <script>
        //提交表单
        function queryModelPlanList() {
            var data = $("#queryForm").serialize();
            window.location.href = "<%=path%>/bus/meter/list?" + data;
        }

        //跳转到支给页面
        function toLssued(modelCode,operator) {
            window.location.href = "<%=path%>/bus/meter/toLssued?modelCode=" + modelCode + "&operator=" + operator;
        }

        //跳转到支给详情页面
        function toLssuedDetails(modelCode) {
            window.location.href = "<%=path%>/bus/meter/toLssuedDetails?modelCode=" + modelCode;
        }

    </script>
<body>
<div class="col-lg-12">
    <div class="index-nav-right">
        <div class="index-nav-right-header"><span>当前位置 > 材料库存</span></div>
    </div>
    <div class="right-table">
        <div class="search-form">

            <div class="search-form-input" style="border: 0px solid red;width:70%;">
                <form id="queryForm" method="post" action="<%=path%>/bus/meter/list">
                    <div style="border: 0px solid red; display: inline">
                        <label>部品番号:</label><input type="text" name="modelCode" id="modelCode"
                                                  value="${map['modelCode'] }"/>
                    </div>
                    <div style="border: 0px solid red; display: inline">
                        <label>厂家:</label>
                        <select name="factory" id="factory" style="width:200px;">
                            <c:if test="${not empty factory}">
                                <option value=""></option>
                                <c:forEach items="${factory }" var="factory" varStatus="m">
                                    <option value="${factory.orgName }"
                                            <c:if test="${map['factory'] ==factory.orgName }">selected</c:if>>${factory.orgName}</option>
                                </c:forEach>
                            </c:if>
                        </select>
                    </div>
                    <button style="margin-left: 20px;color: black;" class="btn btn-primary search-form-btn-s">搜索
                    </button>
                </form>
            </div>

        </div>

        <div class="index-table">
            <table class="table table-striped" action="<%=path%>/bus/meter/list">
                <thead>
                <tr class="table-thead">
                    <th>序号</th>
                    <th>厂家</th>
                    <th>部品番号</th>
                    <th>入库数</th>
                    <th>支给数</th>
                    <th>剩余数</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:if test="${not empty list}">
                    <c:forEach items="${list }" var="meter" varStatus="r">
                        <tr>
                            <td>${r.index+1 }</td>
                            <td>${meter.factory }</td>
                            <td>${meter.modelCode }</td>
                            <td>${meter.inventory }</td>
                            <td>${meter.inventory-meter.avaliablAmount}</td>
                            <td>${meter.avaliablAmount }</td>
                            <td>
                                <span <c:if
                                        test="${meter.inventory > 0}"> class="hand-like" onClick = 'toLssued("${meter.modelCode}","${meter.factory }")'</c:if> >材料支给</span>
                                <span <c:if
                                        test="${meter.inventory > 0}"> class="hand-like" onClick = 'toLssuedDetails("${meter.modelCode}")'</c:if> >详情</span>
                            </td>
                        </tr>
                    </c:forEach>
                </c:if>
                <c:if test="${empty list}">
                    <tr>
                        <td colspan="11"><label class="control-label text-center">无记录</label></td>
                    </tr>
                </c:if>
                </tbody>
                <tr style="background: #f8f8f8">
                    <td colspan="12">
                        <jsp:include page="/WEB-INF/jsp/page.jsp"></jsp:include>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
</body>
</html>